﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using WebStickyNotes.Contracts;
using WebStickyNotes.Contracts.Interfaces;
using WebStickyNotes.Helpers;

namespace WebStickyNotes.Test
{
    [TestClass]
    public class AuditHelperTest
    {

        [TestMethod]
        public void AuditAction_Simple_ExpectCallToDataAccess()
        {
            var mock = new Mock<IWebStickyNotesDataAccess>();
            mock.Expect(data => data.SaveTaskAudit(It.IsAny<TaskAudit>())).Returns(1);

            AuditHelper.AuditAction(mock.Object, "Test", 1);

            mock.VerifyAll();
        }

        [TestMethod]
        public void AuditAction_TaskDetail_ExpectCallToDataAccess()
        {
            var mock = new Mock<IWebStickyNotesDataAccess>();
            mock.Expect(data => data.SaveTaskAudit(It.IsAny<TaskAudit>())).Returns(1);

            var taskDetail = new TaskDetail { Id = 1 };

            AuditHelper.AuditAction(mock.Object, "Test", taskDetail, 1);

            mock.VerifyAll();
        }

        [TestMethod]
        public void AuditAction_TaskPerson_ExpectCallToDataAccess()
        {
            var mock = new Mock<IWebStickyNotesDataAccess>();
            mock.Expect(data => data.SaveTaskAudit(It.IsAny<TaskAudit>())).Returns(1);

            var taskPerson = new TaskPerson { Id = 1 };

            AuditHelper.AuditAction(mock.Object, "Test", taskPerson, 1);

            mock.VerifyAll();
        }

        [TestMethod]
        public void AuditAction_TaskStream_ExpectCallToDataAccess()
        {
            var mock = new Mock<IWebStickyNotesDataAccess>();
            mock.Expect(data => data.SaveTaskAudit(It.IsAny<TaskAudit>())).Returns(1);

            var taskStream = new TaskStream { Id = 1 };

            AuditHelper.AuditAction(mock.Object, "Test", taskStream, 1);

            mock.VerifyAll();
        }

        [TestMethod]
        public void AuditAction_TaskProject_ExpectCallToDataAccess()
        {
            var mock = new Mock<IWebStickyNotesDataAccess>();
            mock.Expect(data => data.SaveTaskAudit(It.IsAny<TaskAudit>())).Returns(1);

            var taskProject = new TaskProject { Id = 1 };

            AuditHelper.AuditAction(mock.Object, "Test", taskProject, 1);

            mock.VerifyAll();
        }

        [TestMethod]
        public void AuditAction_TaskPriority_ExpectCallToDataAccess()
        {
            var mock = new Mock<IWebStickyNotesDataAccess>();
            mock.Expect(data => data.SaveTaskAudit(It.IsAny<TaskAudit>())).Returns(1);

            var taskPriority = new TaskPriority { Id = 1 };

            AuditHelper.AuditAction(mock.Object, "Test", taskPriority, 1);

            mock.VerifyAll();
        }
    }
}
